#include<iostream>
#include<stdlib.h>
#include<string.h>
#define MAX 1000001

using namespace std;

int ncases;
int counter= 1;
int sum[MAX]={0};
int m;

void print() {
   for(int i=0; i<m; i++)
      cout << sum[i];
   if(counter == ncases)
      return;
   counter++;
   cout << endl;
   cout << endl;
}

void solve() {
   for(int i=m; i>0; i--)
      if(sum[i]>=10) {
         sum[i] -= 10;
         sum[i-1] += 1;
      }
   print();
}

void read() {
   int n1, n2;
   int index;
   cin >> ncases;
   for(int i=0; i<ncases; i++) {
      index = 0;
      memset(sum, 0, sizeof(sum));
      cin >> m;
      for(int j=0; j<m; j++) {
         cin >> n1 >> n2;
         sum[index++] = n1+n2;
      }
      solve();
   }
}

int main() {
   read();
   return 0;
}
